home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Utilities / Network / QUE / Basic / quealias.c < prev    next >
C/C++ Source or Header  |  1989-08-03  |  2KB  |  108 lines

  1. /*
  2. ------------------------------------------------------------
  3. Copyright © 1989 Rob Kassel, Mike McCandless and the Massachusetts Institute of Technology
  4.  
  5. Permission to use, copy, modify, and distribute this software and its documentation for any purpose without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of M.I.T. not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.  The authors and M.I.T. make no representations about the suitability of this software for any purpose.  It is provided “as is” without express or implied warranty.
  6. ------------------------------------------------------------
  7. */
  8.  
  9. #include "mail.h"
  10.  
  11.  
  12. main(argc,argv)
  13.  
  14. int argc;
  15. char *argv[];
  16.  
  17.  
  18. {
  19. FILE *fpIn,*fpOut,*fopen();
  20. char nme[MAXLINE],buf[MAXLINE];
  21. char *t;
  22.  
  23.  
  24. if (argc < 2) {
  25.     printf("Usage: %s infile.\n",argv[0]);
  26.     exit(1);
  27. }
  28.  
  29. fpIn = fopen(argv[1],"r");
  30. sprintf(buf,"%s.al",argv[1]);
  31. fpOut = fopen(buf,"w");
  32.  
  33. if (fpIn == NULL || fpOut == NULL) {
  34.     printf("Couldn't open files.\n");
  35.     exit(1);
  36. }
  37.  
  38. while (TRUE) {
  39.     t = fgets(nme,MAXLINE,fpIn);    
  40.     if (t == NULL)
  41.         break;
  42.     fputs(interpret(nme),fpOut);
  43. }
  44.  
  45. fclose(fpIn);
  46. fclose(fpOut);
  47. }
  48.  
  49.  
  50.  
  51.  
  52. char *interpret(buf)
  53.  
  54. char *buf;
  55.  
  56. {
  57. int x,y,cntd;
  58. char fNme[MAXLINE],lNme[MAXLINE];
  59. char drp[MAXLINE];
  60. struct fld theFld;
  61. char *finished,*fQte;
  62. int lp;
  63. char *pStrng;
  64. char theNme[MAXLINE];
  65.  
  66.  
  67. strcpy(theFld.buf,buf);
  68. fieldParse(&theFld);
  69.  
  70. pStrng = theFld.itm[0].txt;
  71.  
  72.  
  73.  
  74. finished = alcCh(MAXLINE); 
  75.  
  76.  
  77. if (theFld.cnt != 3) {
  78.     printf("Alias format wrong,line skipped: %s.\n",theFld.buf);
  79.     return(" ");
  80. }
  81.  
  82. if (*pStrng == (char) 44) {
  83.         strcpy(fNme,pStrng + 1);
  84.         *lNme = '\0';
  85. }
  86.  
  87. if (*(pStrng + strlen(pStrng)) == 44) {
  88.         *(pStrng + strlen(pStrng)) = '\0';
  89.         strcpy(lNme,pStrng);
  90.         *fNme = '\0';
  91. }
  92.  
  93. if (*pStrng != (char) 44 && *(pStrng + strlen(pStrng)) != (char) 44) {
  94.         strncpy(lNme,pStrng,(int) (strchr(pStrng,(char)44) - pStrng));
  95.         *(lNme + (int) (strchr(pStrng,(char)44) - pStrng)) = '\0';
  96.         strcpy(fNme,strchr(pStrng,(char)44) + 1);
  97. }
  98.  
  99.  
  100. sprintf(theNme,"%s %s",fNme,lNme);
  101. strcpy(drp,theFld.itm[2].txt);
  102.  
  103.  
  104. sprintf(finished,"%s: %c|/usr/maildrops/quemail -d %s -u '%s'%c\n",alter(theNme,'_'),(char) 34,drp,theNme,(char)34);
  105.  
  106. return(finished);
  107. }
  108.